/**
 *  文件名:ActivityNickname.java
 *  修改人:lihangjie
 *  创建时间:2015-8-31 上午11:20:38
 */
package com.sharemob.tinchat.modules.account;

import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

import com.sharemob.tinchat.R;
import com.sharemob.tinchat.base.BaseActivity;
import com.sharemob.tinchat.base.ClearEditText;
import com.sharemob.tinchat.lib.common.SMGlobal;
import com.sharemob.tinchat.modules.dao.cache.CacheManager;

/**
 * 
 * <一句话功能简述>
 *
 * @author lihangjie
 * version [版本号,2015-8-31 上午11:20:38]
 * @see    [相关类/方法]
 * @since  [产品/模块版本]
 *
 */
public class ActivityNickname extends BaseActivity {

	  protected void onCreate(Bundle savedInstanceState)
	    {
	        super.onCreate(savedInstanceState);
	        requestWindowFeature(Window.FEATURE_NO_TITLE);
	        setContentView(R.layout.activity_nickname);
	        
	        final ClearEditText nickname = (ClearEditText) findViewById(R.id.et_nickname);
	        nickname.setText(CacheManager.getInstance().getAccount().getNickname());
	        exitView(R.id.title_back,R.anim.activity_close,0);
	        
	        ((Button) findViewById(R.id.title_submit)).setOnClickListener(new OnClickListener() {  
	              
	            @Override  
	            public void onClick(View v) {  
	                if(TextUtils.isEmpty(nickname.getText())){  
	                    //设置晃动  
	                	nickname.setShakeAnimation();  
	                    //设置提示  
	                    showToast("用户名不能为空"); 
	                    
	                    return;  
	                }else{
	                	CharSequence nickName=nickname.getText();
	                	CacheManager.getInstance().getAccount().setNickname(nickName.toString());
	                	Message msg=new Message();
	        			msg.what=ActivityAccountInfo.KeyNickname;
	        			Bundle bundleData = new Bundle();
	        			bundleData.putString("nickname",nickName.toString());
	        			msg.setData(bundleData);
	        			SMGlobal.getInstance().handler.sendMessage(msg);
	                	finishActivity();
	                }
	               
	            }  
	        });  
	    }
	protected void keyEventOfListView(int position, int id) {
		// TODO Auto-generated method stub
		
	}

}
